package com.cjt.common.lang;

import lombok.Data;

@Data
public class R {
    private Integer code;
    private String msg;
    private Object data;

    public static R success(Object data) {
        return success(200, "操作成功", data);
    }
    public static R success(int code, String msg, Object data) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }

    public static R fail(String msg) {
        return fail(400, msg, null);
    }

    public static R fail(String msg, Object data) {
        return fail(400, msg, data);
    }

    public static R fail(int code, String msg, Object data) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }
}
